/**
 * mainWindow.java
 *
 * @author Evan Nelson
 */

package gui;

import java.awt.Dimension;

import javax.swing.JFrame;

/**
 * This is the main window for all GUI components to sit in.  
 * It's created on startup.
 */
public class mainWindow extends JFrame {

	private static final long serialVersionUID = -9106975480614136242L;
	final boolean RIGHT_TO_LEFT = false;
	public static mainWindow mainGUI;
	private Dimension size = new Dimension(800, 500);
			
    private String curUser;
    private int curUserID;
    
   	/**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private void createAndShowGUI() {
    	setTitle("Exercise Manager Login");
		
    	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	setSize(this.size);
    	
    	Main_LoginPanel login = new Main_LoginPanel();
    	setContentPane(login);
    	
		//Display the window.
		setVisible(true);
    }
     
	public static void successfulLogin(int userID, String username) {
		mainGUI.curUserID = userID;
		mainGUI.curUser = username;
		
		mainGUI.setTitle(username + "'s Exercise Manager");
		
		Main_ContentPanel content = new Main_ContentPanel(mainGUI.size);
		mainGUI.setContentPane(content);

    	//Add a menu to the frame
		mainGUI.setJMenuBar(content.generateMenu());
		content.updateUI();
	}
	
	public mainWindow() {
		createAndShowGUI();
	}
    
	public static void main(String[] args) {
		//Schedule a job for the event-dispatching thread:
    	//creating and showing this application's GUI.
    	javax.swing.SwingUtilities.invokeLater(new Runnable() {
    		public void run() {
    			//createAndShowGUI();
    			mainGUI = new mainWindow();
    		}
    	});
    }
}
